﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
    xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" 
    x:Name="userControl" 
    x:Class="MVVM.Client.Views.QuestionnaireTemplateSummaryView"
    mc:Ignorable="d"
    d:DesignHeight="100" d:DesignWidth="400">

    <i:Interaction.Triggers>
        <ei:DataTrigger Binding="{Binding CurrentState}" Value="Normal">
            <ei:GoToStateAction TargetObject="{Binding ElementName=userControl}" StateName="Normal"/>
        </ei:DataTrigger>
        <ei:DataTrigger Binding="{Binding CurrentState}" Value="RequestingSummary">
            <ei:GoToStateAction TargetObject="{Binding ElementName=userControl}" StateName="Working"/>
        </ei:DataTrigger>
    </i:Interaction.Triggers>

    <Border Grid.Row="1" BorderThickness="2" BorderBrush="#FF4E80C4" Background="#FFECECEF" CornerRadius="3" Margin="5">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="Status">

                <VisualStateGroup.Transitions>
                    <VisualTransition To="Working">
                        <Storyboard>
                            <DoubleAnimation Duration="0:0:1" To="0.25" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="TitleLabel" d:IsOptimized="True"/>
                            <DoubleAnimation Duration="0:0:1" To="0.25" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="QuestionsLabel" d:IsOptimized="True"/>
                            <DoubleAnimation Duration="0:0:1" To="0.25" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="TimeLabel" d:IsOptimized="True"/>
                            <DoubleAnimation Duration="0:0:1" To="0.25" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="DescriptionLabel" d:IsOptimized="True"/>
                        </Storyboard>
                    </VisualTransition>

                    <VisualTransition From="Working" To="Normal">
                        <Storyboard>
                            <DoubleAnimation Duration="0:0:0.3" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="TitleLabel" d:IsOptimized="True"/>
                            <DoubleAnimation Duration="0:0:0.3" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="QuestionsLabel" d:IsOptimized="True"/>
                            <DoubleAnimation Duration="0:0:0.3" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="TimeLabel" d:IsOptimized="True"/>
                            <DoubleAnimation Duration="0:0:0.3" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="DescriptionLabel" d:IsOptimized="True"/>
                        </Storyboard>
                    </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="Normal"/>
                <VisualState x:Name="Working"/>

            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <Grid Margin="2">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition Height="2"/>
                <RowDefinition/>
            </Grid.RowDefinitions>

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="10"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="10"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <TextBlock Text="Title: " Grid.Row="0" Grid.Column="0" FontWeight="SemiBold" x:Name="TitleLabel"/>
            <TextBlock Text="{Binding QuestionnaireTemplateSummary.Title}" Grid.Row="0" Grid.Column="1"/>

            <TextBlock Text="Questions: " Grid.Row="0" Grid.Column="3" FontWeight="SemiBold" x:Name="QuestionsLabel"/>
            <TextBlock Text="{Binding QuestionnaireTemplateSummary.NumberOfQuestions}" Grid.Row="0" Grid.Column="4"/>

            <TextBlock Text="Estimated time: " Grid.Row="0" Grid.Column="6" FontWeight="SemiBold" x:Name="TimeLabel"/>
            <TextBlock Text="{Binding QuestionnaireTemplateSummary.EstimatedTime}" Grid.Row="0" Grid.Column="7"/>

            <TextBlock Text="Description: " Grid.Row="2" Grid.Column="0" FontWeight="SemiBold" x:Name="DescriptionLabel"/>
            <TextBlock Text="{Binding QuestionnaireTemplateSummary.Description}" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="7"/>
        </Grid>
    </Border>
</UserControl>
